﻿@namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm
@inherits ApmComponentBase
@page "/apm/errors"
<PageTitle>@I18n.Apm("PageTitles.Error")</PageTitle>

<ApmSearchComponent Value="Search" ShowExceptError
                    ValueChanged="LoadASync" @ref="ApmSearchComponent" />
<SDataTable Headers="headers"
            Stripe
            FixedHeader
            ServerItemsLength="total"
            ItemsPerPage="defaultSize"
            Items="data"
            MustSort
            TItem="ErrorMessageDto"
            Loading="@isTableLoading"            
            OnOptionsUpdate="OnTableOptionsChanged">
    <ItemColContent>
        @if (context.Header.Value == nameof(ErrorMessageDto.Type))
        {
            <a style="text-decoration:none" onclick="@(()=>Show(context.Item.Type))">@context.Item.Type</a>
        }
        else if (context.Header.Value == nameof(ErrorMessageDto.Message))
        {
            <MTooltip Top Context="tooltipContent">
                <ActivatorContent>
                    <div @attributes="@tooltipContent.Attrs" style="width:400px;cursor:pointer" class="text-truncate" @onclick="@(()=>Show(context.Item.Type,context.Item.Message))">
                        <a style="text-decoration:none" onclick="javascript:;">@context.Item.Message</a>
                    </div>
                </ActivatorContent>
                <ChildContent>
                    <span>@context.Item.Message</span>
                </ChildContent>
            </MTooltip>
        }
        else if (context.Header.Value == nameof(ErrorMessageDto.LastTime))
        {
            @context.Item.LastTime.UtcFormatLocal(CurrentTimeZone)
        }
        else
        {
            @context.Item.Total
        }
    </ItemColContent>
</SDataTable>
<style>
    .m-data-table .m-data-table__wrapper {
        height: calc(100vh - 300px)
    }
</style>
<MCard Rounded=true Class="px-6 py-2" Style="border-top-left-radius: 0 !important; border-top-right-radius: 0 !important;">
    <SPagination Class="mt-2" @bind-Page="page" @bind-PageSize=defaultSize Total=total OnChange="OnPageChange" />
</MCard>

<SSheetDialog Value="showDetail" ValueChanged="Hide" Title="@(Search.ExceptionMsg??Search.ExceptionType)">
    <ErrorDetail SearchData="@Search" Show="showDetail" />
</SSheetDialog>